What is an instance method?

An instance method is a method that operates on an instance of a class. It can access and modify the state of the instance it is called on, as well as any other instance variables or methods of the class.

Instance methods are defined within the class definition using the "def" keyword and are called on an instance using dot notation, as in object.instance_method(). They can take arguments, either mandatory or optional, and can also return a value.

Instance methods are useful for performing operations specific to an instance of a class, such as setting and getting the values of instance variables or performing calculations based on the state of the instance. They can also be used to call other instance methods within the class. Overall, instance methods play an essential role in object-oriented programming by allowing objects to interact with each other and perform complex operations.